/**
 * @file bull_hal_drv_wifi.h    
 * @brief 
 * @author yejing (yejh@gongniu.cn)
 * @version 1.0
 * @date 2024-05-09
 * 
 * Copyright 2021-2023 GongNiu Inc. All Rights Reserved.
 * 
 */

#ifndef BULL_HAL_DRV_WIFI_H_
#define BULL_HAL_DRV_WIFI_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "bull_hal_adapter.h"

typedef enum {
    BULL_WIFI_IF_STA,
    BULL_WIFI_IF_AP,
#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2)
    BULL_WIFI_IF_NAN,
#endif
    BULL_WIFI_IF_MAX
} bull_wifi_interface_t;

/**
 * @brief scan current environment and obtain all the ap
 *        infos in current environment
 * 
 * @param ap_ary 
 * @return int 返回扫描到的AP个数
 */
int bull_hal_drv_wifi_all_ap_scan(AP_IF_S **ap_ary, uint16_t *num);


/**
 * @brief get wifi interface work channel
 * 
 * @param[out]      chan        the channel wifi works
 * @return  OPRT_OS_ADAPTER_OK: success  Other: fail
 */
int bull_hal_drv_wifi_get_cur_channel(uint8_t *chan);


/**
 * @brief get wifi ip info.when wifi works in
 *        ap+station mode, wifi has two ips.
 * 
 * @param[in]       wf          wifi function type
 * @param[out]      ip          the ip addr info
 * @return  OPRT_OS_ADAPTER_OK: success  Other: fail
 */
int bull_hal_drv_wifi_get_ip(const WF_IF_E wf, NW_IP_S *ip);


/**
 * @brief get wifi mac info.when wifi works in
 *        ap+station mode, wifi has two macs.
 * 
 * @param[in]       wf          wifi function type
 * @param[out]      mac         the mac info
 * @return  OPRT_OS_ADAPTER_OK: success  Other: fail
 */
int bull_hal_drv_wifi_get_mac(const WF_IF_E wf, NW_MAC_S *mac);


/**
 * @brief connect wifi with ssid and passwd
 * 
 * @param[in]       ssid              const char *
 * @param[in]       passwd
 * @return  OPRT_OS_ADAPTER_OK: success  Other: fail
 */
// only support wap/wap2 
int bull_hal_drv_wifi_station_connect(const char *ssid, const char *passwd);



/**
 * @brief 断开wifi连接
 * 
 * @return int 
 */
int bull_hal_drv_wifi_station_disconnect(void);


/**
 * @brief get wifi connect rssi
 * 
 * @param[out]      rssi        the return rssi
 * @return  OPRT_OS_ADAPTER_OK: success  Other: fail
 */
int bull_hal_drv_wifi_station_get_conn_ap_rssi(signed char *rssi);

/**
 * @brief 获取当前wifi ssid和passwd
 * 
 * @param interface 
 * @param ssid 
 * @param passwd 
 * @return int 
 */
int bull_hal_drv_wifi_get_ssid_password ( bull_wifi_interface_t interface, OUT char *ssid, OUT char *passwd );

/**
 * @brief 初始化wifi
 * 
 * @param ctx 注册到wifi上的回调函数结构体
 * @return int 
 */
int bull_hal_drv_wifi_init(BULL_WIFI_REG_T *ctx);




#ifdef __cplusplus
}
#endif


#endif 




